package com.cis467.httpsender;



public final class GameManagement{
	
	/*
	 * handle new high score
	 */
	public static void new_highScore(HighScore new_HighScore){
		//LocalManagement phone = new LocalManagement();
		// 
		// if(phone.isNewHS(new_HighScore)){
		//    phone.setHS(new_HighScore);
		//    run  online management server upload method
		//    OnlineManagment server = new OnlineManagement();
		//    try {
		//       server.upload_HS(new_HighScore.toString);
		//    }catch (Exception e){
		//	return -1;
		// }
		//}	
	}
	
	/*
	 * returns the top 10 local high scores for level
	 */
	public static HighScore[] get_myHighScore(MBLevel mbLevel){
		HighScore[] myHighScores = new HighScore[10];
		/* try{
		 * myHighScores = LocalManagement.getHighScores(mbLevel.getlevelName(), mbLevel.getUserName());
		 * }catch (Exception e){
		 *  // error - no Highscores for level
		 * }
		 */		
		
		for (int i = 0; i < myHighScores.length; i++){
			myHighScores[i] = new HighScore();
		}	
		return myHighScores;
	}
	
	/*
	 * returns the top 10 high scores globally for the level
	 */
	public static HighScore[] download_HighScores(MBLevel mbLevel){
		/*
		 * try{
		 * lvlHighScores = OnlineManagement.downloadHighScores(mbLevel);
		 * }catch (Exception e){
		 *  // error - no Online Highscores for level
		 * }
		 */
		
		HighScore[] lvlHighScores = get_myHighScore(mbLevel);
		
		return lvlHighScores;		
	}
	
	/*
	 * returns a level object from the server based on lvl unique key
	 */
	public static MBLevel download_MBLevel(String lvlName, String userName){
		/*
		 * try {
		 * MBLevel downloaded_lvl = OnlineManagement.download_lvl(lvlName, userName);
		 * } catch (Exception e){
		 *  // error - no such level
		 * }
		 */ 
		return new MBLevel();
	}
	
	/*
	 * submits a user created level to the Server
	 */
	public static int upload_MBLevel(MBLevel submitLevel){
		/*
		 * try { 
		 *    OnlineManagement.upload_lvl(submitLevel);
		 * }catch(Exception e){
		 *  // error - Level already exists (return success)
		 *  return 0; success
		 *  // error - integrity errors - alert
		 *  return -1; error
		 * }   
		 */
		return 0; //success
	}
	
	//currently undefined
	/*
	 * returns 10 level segments based on a user query
	 * this should be used when displaying previews of levels for to download
	 */
	public static MBLevel[] queryLevels(String query){
		MBLevel[] lvlChoices =  new MBLevel[10];//OnlineManagement.getLevels(query);
		for (int i = 0; i < lvlChoices.length; i++){
			lvlChoices[i] = new MBLevel();
		}	
		return lvlChoices;
		
	}
	
}